package demo1229.lining;

public class BunStore extends Thread {
    Bun bun;

    public BunStore(Bun bun) {
        this.bun = bun;
    }

    @Override

    public void run() {
        int count =0;
        while (true){
            synchronized (bun){

                if(bun.isEmpty()){

                    try {
                        bun.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                }

                System.out.println("老板开始做包子");
                if(count % 3 ==1){
                    bun.setPi("薄皮");
                    bun.setXian("牛肉粉丝");
                }else if(count %3 ==2){

                    bun.setPi("薄皮");
                    bun.setXian("韭菜");
                }else {
                    bun.setPi("薄皮");
                    bun.setXian("卷心菜");
                }
                count++;
                bun.setEmpty(true);
                System.out.println("老板做好了包子");
                bun.notify();



            }


        }

    }
}
